#*****************************************************************
#  name         : ssh
#  remark       : ssh server on centos
#  tag          : latest
#  level        : service
#  author       : mason
#  build shell  : docker build -t 10.100.135.125:5000/ssh:latest .
#  run shell    : docker run -d -P --name ssh 10.100.135.125:5000/ssh:latest .
#  push shell   : docker push 10.100.135.125:5000/ssh:latest
#  pull shell   : docker pull 10.100.135.125:5000/ssh:latest
#*****************************************************************

FROM 10.100.135.125:5000/centos:7.0

MAINTAINER "mason" <masl@mail.open.com.cn>


ENV SSHUSER sshadmin
ENV SSH_ROOT_PW "!QAZXDR%2016"
RUN yum install -y openssh openssh-server && \
    yum clean all && \
    mkdir /var/run/sshd && \
    ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key && \
    ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key && \
    /bin/echo "root:$SSH_ROOT_PW" |chpasswd && \
    /bin/sed -i 's/.*session.*required.*pam_loginuid.so.*/session optional pam_loginuid.so/g' /etc/pam.d/sshd

EXPOSE 22

COPY ./files/shell/build_run.sh /data/shell/
COPY ./files/shell/docker_run.sh /data/shell/

RUN chmod 777 /data/shell/build_run.sh && \
    chmod 777 /data/shell/docker_run.sh && \
    sh /data/shell/build_run.sh

ENTRYPOINT /data/shell/docker_run.sh && /usr/sbin/sshd -D
